package org.penguin.study.bk.entity

import com.baomidou.mybatisplus.annotation.TableId
import com.baomidou.mybatisplus.annotation.TableName
import io.swagger.v3.oas.annotations.media.Schema
import org.hibernate.annotations.GenericGenerator
import org.penguin.study.bk.base.api.UUIDEntity

import javax.persistence.*
import kotlin.jvm.Transient

@Entity
@Table(name = "tbl_messages")
@org.springframework.data.relational.core.mapping.Table("tbl_messages")
@GenericGenerator(name = "jpa-uuid", strategy = "uuid")
@TableName("tbl_messages")
@Schema(title = "消息对象")
data class Message(
    @Id
    @TableId
    @GeneratedValue(generator = "jpa-uuid")
    @Schema(title = "消息主键")
    var id: String? = null,
    @Schema(title = "消息内容")
    var text: String? = null,
    @Schema(title = "消息确认状态")
    var checked: Boolean? = null
) : UUIDEntity() {
    var checkedUsername: String? = null

    @Transient
    var checkedText: String? = null
        get() = checked?.let { if (it) "已审批" else "被拒绝" } ?: "待审批"
}